package Day1;

import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

/**
 * 2020JavaB真题: 数字三角形
 * https://www.lanqiao.cn/problems/505/learning/?problem_list_id=2&page=1&tags=2020&tag_relation=union
 */
public class Main4 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        int[][] arr = new int[n+1][n+1];
        int[][] dp = new int[n+1][n+1];

        for(int i = 1; i <= n; i++){
          for(int j = 1; j <= i; j++){
            arr[i][j] = scan.nextInt();
          }
        }

        for(int i = 1; i <= n; i++){
          for(int j = 1; j <= i; j++){
            dp[i][j] = Math.max(dp[i-1][j-1] , dp[i-1][j]) + arr[i][j];
          }
        }

        if(n % 2 == 0){
          System.out.println(Math.max(dp[n][n / 2] , dp[n][n / 2 + 1]));
        }else{
          System.out.println(dp[n][(n + 1) / 2]);
        }
        scan.close();
    }
}